<script>
import { mapState } from "vuex";

export default {
  computed: {
    ...mapState({
      router: (state) => state.permission.addRoutes,
    }),
  },
  created() {
    var vm = this;
    var res = this.router;
    var redirect;
    if (res.length > 0) {
      redirect = this.router[0].path;
      if (this.router[0].children) {
        redirect = this.router[0].children[0].path;
      }
    } else {
      redirect = "/dashboard";
    }
    vm.$router.push(redirect);
  },
  render: function (h) {
    return h(); // avoid warning message
  },
};
</script>